package org.flint.data.structure.queue;

import org.flint.data.structure.heap.MaxHeap;

/**
 * @author flint92
 */
public class PriorityQueue<E extends Comparable<E>> implements Queue<E> {

    private final MaxHeap<E> heap;

    public PriorityQueue() {
        this.heap = new MaxHeap<>();
    }

    public PriorityQueue(int capacity) {
        this.heap = new MaxHeap<>(capacity);
    }

    @Override
    public int getSize() {
        return heap.size();
    }

    @Override
    public boolean isEmpty() {
        return heap.isEmpty();
    }

    @Override
    public void enqueue(E e) {
        heap.add(e);
    }

    @Override
    public E dequeue() {
        return heap.extractMax();
    }

    @Override
    public E getFront() {
        return heap.findMax();
    }
}
